
Class ContentManager(Of T)
    Dim Contents As New ArrayList
    Structure ContentItem
        Dim Index As Integer
        Dim Content As T
    End Structure
    Public Function ItemExists(ByVal Index As Integer) As Boolean
        For x As Integer = 0 To Contents.Count - 1
            Dim tItem As ContentItem = CType(Contents(x), ContentItem)
            If tItem.Index = Index Then Return True
        Next
        Return False
    End Function
    Public Function GetItem(ByVal Index As Integer) As T
        For x As Integer = 0 To Contents.Count - 1
            Dim tItem As ContentItem = CType(Contents(x), ContentItem)
            If tItem.Index = Index Then Return tItem.Content
        Next
        Return Nothing
    End Function
    Public Sub AddItem(ByVal Index As Integer, ByRef Content As T)
        Dim tItem As New ContentItem
        tItem.Index = Index
        tItem.Content = Content
        Contents.Add(tItem)
    End Sub
    Public Sub UpdateItem(ByVal Index As Integer, ByRef Content As T)
        For x As Integer = 0 To Contents.Count - 1
            Dim tItem As ContentItem = CType(Contents(x), ContentItem)
            If tItem.Index = Index Then
                tItem.Content = Content
                Contents(x) = tItem
            End If
        Next
    End Sub
    Public Sub Clear()
        Contents.Clear()
        GC.Collect()
    End Sub
End Class
